package com.weinisuo.share.mybatis.plus.table;

import org.springframework.util.StringUtils;


public class BeautyButlerStrategy implements Strategy {

    @Override
    public String returnTableName(String tableName) {
        if ( !StringUtils.hasText(tableName) ){
            throw  new IllegalArgumentException("表名不能为空");
        }else {
            String threadTableName = TablesNameHolder.getThreadTableName();
            if (StringUtils.hasText(threadTableName)) {
                String mod8Table = BeautyButlerSourceSelect.getMod8Table(Integer.parseInt(threadTableName));
                TablesNameHolder.removeThreadTableName();
                return tableName + "_" + mod8Table;
            } else {
                throw new IllegalArgumentException("无法找到对应的表名,请设置==TablesNameHolder");
            }
        }
    }

}
